package com.ruoyi.framework.config;

import com.ruoyi.common.config.RuoYiConfig;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import com.ruoyi.common.utils.StringUtils;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    /** 本地文件存储路径（取自配置） */
    private final String FILE_PATH = System.getProperty("user.dir") + "/src/main/resources/static/upload/";

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 映射 /upload/** 到本地存储路径
        registry.addResourceHandler("/upload/**")
                .addResourceLocations("file:" + RuoYiConfig.getProfile() + "/");
    }
}